<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * 
 * @author liubin-bt
 * @property User_model $User_model
 */
class User extends Base {

    public function __construct(){
        parent::__construct();
    }
    
    public function loginInfo(){
        $user = $this->session->user;
        if( !$user ){
            $this->outJsonData(-1, '用户未登录');
        }
        $this->outJsonData(0, $user);
    }
    
    public function loginOut(){
        $this->session->user = '';
        $this->outJsonData(0, '退出成功');
    }
    
    public function search(){
        $keyword = $this->getSafeRequest('keyword', '');
        /* if( !$keyword ){
            $this->outJsonData(-1, '搜索内容不能为空');
        } */
        $this->load->model('User_model');
        $list = $this->User_model->search_uname($keyword, $this->user['corp_id']);
        foreach ($list as &$v){
            $v['label'] = $v['user_name'];
        }
        $this->outJsonData(0, $list);
    }
}
?>